#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using XcoAppSpaces.Contracts.Transport;

namespace XcoAppSpaces.Transport.WCF
{
	/// <summary>
	/// Interface definition for the WCF service used to communication with remote spaces.
	/// All communication is one-way and session oriented.
	/// </summary>
	[ServiceContract(SessionMode=SessionMode.Required)]
    public interface IRemoteSpaceService 
	{
		//For our source never use -> IsOneWay = true -> no error detection!
		//From MS-Dokumentation:
		//Use the IsOneWay property to indicate that an operation does not return a 
		//reply message. This type of operation is useful for notifications or 
		//event-style communication, especially in two-way communication. 
		//Without waiting for an underlying response message, callers of one-way 
		//operations have no direct way to detect a failure in processing the 
		//request message. (Service applications that use reliable channels and 
		//one-way operations can detect a message delivery failure at the channel level.


		/// <summary>
		/// Initiates a connection to a remote space. This is always the first Method that
		/// has to be called when wanting to communicate with a remote space.
		/// </summary>
		[OperationContract(IsInitiating = true, IsTerminating = false)]
		void Connect();
		
		/// <summary>
		/// Terminates the connection to a remote space. This is always the last Method that
		/// has to be called when wanting to communicate with a remote space.
		/// </summary>
		[OperationContract(IsInitiating = false, IsTerminating = true)]
		void Disconnect();
		
		/// <summary>
		/// Sends a message to a remote space (serialized into a byte array).
		/// </summary>
		/// <param name="data">The message to be sent.</param>
		/// <param name="remoteAddress">The address of the space from which the message has been sent.</param>
		[OperationContract( IsInitiating = false, IsTerminating = false)]
        void SendMessage(XcoMessage data, string remoteAddress);
	}

	/// <summary>
	/// Interface definition for the service channel of the space.
	/// </summary>
    public interface SpaceServiceChannel : IRemoteSpaceService, IClientChannel { }
}
